//
//  SetAboutView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2024/12/26.
//

import SwiftUI

struct SetAboutView: View {
    @EnvironmentObject var pathManager : PathManager
    
    var body: some View {
        HStack{
            VStack(alignment: .leading, spacing: 10) {
                Text("关于")
                    .foregroundColor(.bgItemContent)
                    .fontWeight(.bold)
                    .font(.system(size: 14))
                HStack {
                    Text("隐私协议")
                        .font(.system(size: 14))
                        .foregroundColor(.bgItemContent)
                    Spacer()
                    Image(systemName: "arrow.right.circle.fill")
                        .resizable()
                        .scaledToFit()
                        .foregroundColor(.gray.opacity(0.5))
                        .frame(width: 15, height: 15)
                        .clipped()
                }.padding(.top,5).padding(.bottom,5)
                    .contentShape(Rectangle())// 将整个矩形区域（包括padding）都设置为可点击区域
                    .onTapGesture {
                        let jumpData = JumpData(url: "http://cdn.aiyuxm.com/config/privacy/imprint_privacy8.html",title: "隐私协议")
                        pathManager.jump(type: JumpType.WEB_VIEW, data: jumpData)
                    }
                HStack {
                    Text("用户协议")
                        .font(.system(size: 14))
                        .foregroundColor(.bgItemContent)
                    Spacer()
                    Image(systemName: "arrow.right.circle.fill")
                        .resizable()
                        .scaledToFit()
                        .foregroundColor(.gray.opacity(0.5))
                        .frame(width: 15, height: 15)
                        .clipped()
                }.padding(.top,5).padding(.bottom,5)
                    .contentShape(Rectangle())// 将整个矩形区域（包括padding）都设置为可点击区域
                    .onTapGesture {
                        let jumpData = JumpData(url: "http://cdn.aiyuxm.com/config/privacy/service_agreement_imprint.html",title: "用户协议")
                        pathManager.jump(type: JumpType.WEB_VIEW, data: jumpData)

                    }
                HStack {
                    Text("版本号")
                        .font(.system(size: 14))
                        .foregroundColor(.bgItemContent)
                    Spacer()
                    Text("\(getAppVersionAndBuild().0)")
                        .font(.system(size: 12))
                        .foregroundColor(.bgItemContent2)
                }.padding(.top,5).padding(.bottom,5)
            }
            Spacer()
        }.frame(maxWidth: .infinity).padding().background(.bgItem).clipShape(RoundedRectangle(cornerRadius: 15))
    }
}

//#Preview {
//    SetAboutView()
//}

struct SetAbout_Previews: PreviewProvider {
    static var previews: some View {
        //使用预览共享配置
        configurePreviewEnvironment(for: SetAboutView())
    }
}
